using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel.Design;
using System.Web.UI.Design;

namespace BlogControl
{
    class DesignerActionsList : DesignerActionList
    {
        BlogDesigner _controlDesigner;
        DesignerActionUIService _designerActionUISvc;

        public DesignerActionsList(BlogDesigner designer)
            : base(designer.Component)
        {
            _designerActionUISvc = GetService(typeof(DesignerActionUIService)) as DesignerActionUIService;
            _controlDesigner = designer; 
        }
        public bool ShowAddPostButton
        {
            get { return ((Blog)this.Component).ShowAddPostButton; }
            set
            {
                ((Blog)this.Component).ShowAddPostButton = value;
                _designerActionUISvc.Refresh(this.Component);
            }
        }

        public bool ShowFullBlogsOnPreivewPage
        {
            get { return ((Blog)this.Component).ShowFullBlogsOnPreivewPage; }
            set
            {
                ((Blog)this.Component).ShowFullBlogsOnPreivewPage = value;
                _designerActionUISvc.Refresh(this.Component);
            }
        }


        public bool ShowCommentsCountOnPreviewPage
        {
            get { return ((Blog)this.Component).ShowCommentsCountOnPreviewPage; }
            set
            {
                ((Blog)this.Component).ShowCommentsCountOnPreviewPage = value;
                _designerActionUISvc.Refresh(this.Component);
            }
        }

        public override DesignerActionItemCollection GetSortedActionItems()
        {
            DesignerActionItemCollection col = new DesignerActionItemCollection();
            DesignerActionHeaderItem hi = new DesignerActionHeaderItem("Appearance settings", "Appearance");
            col.Add(hi);

            DesignerActionPropertyItem pi = new DesignerActionPropertyItem("ShowAddPostButton", "Show the \"Add Post\" button", "Appearance", "Check to show the \"Add Post\" button");
            col.Add(pi);

            pi = new DesignerActionPropertyItem("ShowFullBlogsOnPreivewPage", "Show full posts text on the first page", "Appearance", "Check to show full posts text on the first page");
            col.Add(pi);

            pi = new DesignerActionPropertyItem("ShowCommentsCountOnPreviewPage", "Show comments count next to each post on the first page", "Appearance", "Check to show comments count for each post on the first page");
            col.Add(pi);
            return col; 
        }
    }
}
